import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.figure(figsize=(5,5))
x = [3,4,5,2,6]
y = [25,35,39,20,41]
plt.scatter(x,y)
plt.xlabel("Height in feet")
plt.ylabel("Weight in KG")
plt.savefig("height-weight-scatterplot.eps", format='eps',transparent=True)

x = [0,1,2,3]
y = [0,1,2,3]
plt.scatter(x,y)
plt.xlabel('x')
plt.ylabel('y')
plt.savefig("scatterplot-2.eps", format='eps',transparent=True)

# plt.figure(fig)
x = [0,1,2,3]
y = [0,1,2,3]
plt.scatter(x,y,label="Ordinary data")
plt.scatter([4],[0],label="Outlier")
plt.xlabel('x')
plt.ylabel('y')
# plt.legend(loc=(1.04,0)
plt.legend()
plt.savefig("scatterplot-3.eps", format='eps',transparent=True)
The PostScript backend does not support transparency; partially transparent artists will be rendered opaque.
The PostScript backend does not support transparency; partially transparent artists will be rendered opaque.

from sklearn.linear_model import LinearRegression
x = np.array(x).reshape((-1,1))
y = np.array(y).reshape((-1,1))
model = LinearRegression()
model.fit(x,y)
prediction = model.predict(x)
plt.scatter(x,y)
plt.xlabel('x')
plt.ylabel('y')
plt.plot(x,prediction,label="Learnt Model")
for i in range(len(x)):
  plt.plot([x[i],x[i]],[prediction[i],y[i]],'r')
plt.legend()
plt.savefig("linear-fit.eps", format='eps',transparent=True)
The PostScript backend does not support transparency; partially transparent artists will be rendered opaque.
The PostScript backend does not support transparency; partially transparent artists will be rendered opaque.

fig, ax = plt.subplots()
x = np.linspace(-10,10,100)
x = x[x<=0]
y = func(x)


val = -7.2

plt.scatter([val],func(np.array([val])))
ax.annotate('local minima', xy=(val, func(val)), xytext=(val, 1),
            arrowprops=dict(facecolor='black', shrink=0.05))
plt.xticks([])
plt.yticks([])
plt.plot(x,y)

x
array([-10.        ,  -9.7979798 ,  -9.5959596 ,  -9.39393939,
        -9.19191919,  -8.98989899,  -8.78787879,  -8.58585859,
        -8.38383838,  -8.18181818,  -7.97979798,  -7.77777778,
        -7.57575758,  -7.37373737,  -7.17171717,  -6.96969697,
        -6.76767677,  -6.56565657,  -6.36363636,  -6.16161616,
        -5.95959596,  -5.75757576,  -5.55555556,  -5.35353535,
        -5.15151515,  -4.94949495,  -4.74747475,  -4.54545455,
        -4.34343434,  -4.14141414,  -3.93939394,  -3.73737374,
        -3.53535354,  -3.33333333,  -3.13131313,  -2.92929293,
        -2.72727273,  -2.52525253,  -2.32323232,  -2.12121212,
        -1.91919192,  -1.71717172,  -1.51515152,  -1.31313131,
        -1.11111111,  -0.90909091,  -0.70707071,  -0.50505051,
        -0.3030303 ,  -0.1010101 ,   0.1010101 ,   0.3030303 ,
         0.50505051,   0.70707071,   0.90909091,   1.11111111,
         1.31313131,   1.51515152,   1.71717172,   1.91919192,
         2.12121212,   2.32323232,   2.52525253,   2.72727273,
         2.92929293,   3.13131313,   3.33333333,   3.53535354,
         3.73737374,   3.93939394,   4.14141414,   4.34343434,
         4.54545455,   4.74747475,   4.94949495,   5.15151515,
         5.35353535,   5.55555556,   5.75757576,   5.95959596,
         6.16161616,   6.36363636,   6.56565657,   6.76767677,
         6.96969697,   7.17171717,   7.37373737,   7.57575758,
         7.77777778,   7.97979798,   8.18181818,   8.38383838,
         8.58585859,   8.78787879,   8.98989899,   9.19191919,
         9.39393939,   9.5959596 ,   9.7979798 ,  10.        ])
x[y==val]
array([-2.12121212])
val
-2.3745682396702437
y[x<25]
array([ 1.69351335,  1.47131924,  1.22371576,  0.9587681 ,  0.684928  ,
        0.41069988,  0.14430802, -0.10662173, -0.33535303, -0.53629097,
       -0.70518496, -0.83927443, -0.93737161, -0.99987837, -1.02873658,
       -1.02731441, -1.00023337, -0.9531436 , -0.89245674, -0.82504765,
       -0.7579375 , -0.69797133, -0.65150368, -0.62410537, -0.62030365,
       -0.64336659, -0.69514097, -0.77595027, -0.88455735, -1.01819364,
       -1.17265367, -1.34245142, -1.5210323 , -1.7010322 , -1.8745732 ,
       -2.033584  , -2.17013196, -2.2767534 , -2.34676854, -2.37456824,
       -2.35586079, -2.28786853, -2.16946611, -2.00125462, -1.7855683 ,
       -1.52641324, -1.22934038, -0.90125763, -0.55018832, -0.18498567,
        0.18498567,  0.55018832,  0.90125763,  1.22934038,  1.52641324,
        1.7855683 ,  2.00125462,  2.16946611,  2.28786853,  2.35586079,
        2.37456824,  2.34676854,  2.2767534 ,  2.17013196,  2.033584  ,
        1.8745732 ,  1.7010322 ,  1.5210323 ,  1.34245142,  1.17265367,
        1.01819364,  0.88455735,  0.77595027,  0.69514097,  0.64336659,
        0.62030365,  0.62410537,  0.65150368,  0.69797133,  0.7579375 ,
        0.82504765,  0.89245674,  0.9531436 ,  1.00023337,  1.02731441,
        1.02873658,  0.99987837,  0.93737161,  0.83927443,  0.70518496,
        0.53629097,  0.33535303,  0.10662173, -0.14430802, -0.41069988,
       -0.684928  , -0.9587681 , -1.22371576, -1.47131924, -1.69351335])
func([1.4])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-69-a7647ebf0a8e> in <module>
----> 1 func([1.4])

<ipython-input-66-27f8a49456fd> in func(x)
      1 def func(x):
----> 2     return np.sin(x) + np.sin(x/2) + np.sin(x/3)

TypeError: unsupported operand type(s) for /: 'list' and 'int'